//
//  UIView+layer.m
//  LZNeiHan
//
//  Created by 梁梓烽 on 16/10/1.
//  Copyright © 2016年 liangzifeng. All rights reserved.
//

#import "UIView+layer.h"

@implementation UIView (layer)
/** 统一设置接口 */
-(void)setLayerCornerRadius:(CGFloat)layerCornerRadius  layerBorderWidth:(CGFloat)layerBorderWidth layerBorderColor:(UIColor*)layerBorderColor
{
    self.layer.cornerRadius = layerCornerRadius;
    self.layer.borderWidth  =layerBorderWidth;
    self.layer.borderColor  = layerBorderColor.CGColor;
    self.layer.masksToBounds =YES;
}

/** CornerRadius */
-(void)setLayerCornerRadius:(CGFloat)layerCornerRadius
{
    self.layer.cornerRadius = layerCornerRadius;
    [self config];

}
-(CGFloat)layerCornerRadius
{
    return self.layer.cornerRadius;
}

/** BorderWidth */
-(void)setLayerBorderWidth:(CGFloat)layerBorderWidth
{
    self.layer.borderWidth=layerBorderWidth;
    [self config];
}

-(CGFloat)layerBorderWidth
{
    return  self.layer.borderWidth;
}

/** BorderColor */
-(void)setLayerBorderColor:(UIColor *)layerBorderColor
{
    self.layer.borderColor = layerBorderColor.CGColor;
    [self config];
}

-(UIColor *)layerBorderColor
{
    return  [UIColor colorWithCGColor:self.layer.borderColor];
}

/** 对layer的统一配置 */
-(void)config
{
    self.layer.masksToBounds =YES;
    //设置 layer 栅格化 ,设置栅格化后，图层会被渲染成图片，并且缓存，再次使用时，不会重新渲染
    self.layer.rasterizationScale = [UIScreen mainScreen].scale;
    self.layer.shouldRasterize = YES;
}
@end
